import datetime

class Serie(object):

    def __init__(self, n, i=None):
        self.name = n
        self.id = i

    def data(self):
        idValue = 'NULL' if self.id == None else str(self.id)
        return idValue + ', "' + self.name + '"'

    def __str__(self):
        return str(self.name)

    def __eq__(self, other):
        return self.name == other.name


class Calendar(object):

    month = {'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6, 'July':7,
        'August':8, 'September':9, 'October':10, 'November':11, 'December':12}

    def __init__(self, ser, epi, sea, nro, da=datetime.date.today(), i=None):
        self.id = i
        self.serie = ser
        self.nroEp = nro
        self.episode = epi.replace('"', '')
        self.season = sea
        dateInfo = str(da).split(' ') if str(da).find('-') == -1 else str(da).split('-')
        if len(str(dateInfo[2])) > 2:
            if da.find(',') != -1:
                self.date = datetime.date(int(dateInfo[2]), Calendar.month[dateInfo[0]], int(dateInfo[1][:-1]))
            else:
                self.date = datetime.date(int(dateInfo[2]), Calendar.month[dateInfo[1]], int(dateInfo[0]))
        else:
            self.date = datetime.date(int(dateInfo[0]), int(dateInfo[1]), int(dateInfo[2]))

    def data(self):
        idValue = 'NULL' if self.id == None else str(self.id)
        return str(idValue) + ', "' + self.serie + '" , "' + self.episode + '" , ' + str(self.season) + ', "' + str(self.date) + '", ' + str(self.nroEp)

    def __str__(self):
        return str(self.id) + ', "' + self.serie + '" , "' + self.episode + '" , ' + str(self.season) + ', "' + str(self.date) + '", ' + str(self.nroEp)
